from multiprocessing import Process,Lock
import time
 
def f(x,lock):
    lock.acquire()
    print(x+'1',id(lock))
    time.sleep(5)
    print(x+'2',id(lock))
    lock.release()
 
if __name__=='__main__':
    lock=Lock()
    p1=Process(target=f,args=('x',lock))
    p2=Process(target=f,args=('y',lock))
    p1.start()
    p2.start()
    p1.join()
    p2.join()
